package cn.codexin.wechatofficial.exception;

import cn.codexin.wechatofficial.dto.AccessTokenDTO;
import cn.codexin.wechatofficial.dto.UserInfoAccessTokenDTO;
import cn.codexin.wechatofficial.dto.WeChatResultDTO;

/**
 * Created by xinGao 2020/4/23
 */

public class WeChatExceptionCode implements IExceptionCode {
    private Integer code;
    private String message;

    public WeChatExceptionCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    //访问微信api时候产生的异常码
    public WeChatExceptionCode(WeChatResultDTO result) {
        this.code = result.getErrcode();
        this.message = result.getErrmsg();
    }

    //获取token时候产生的异常码
    public WeChatExceptionCode(AccessTokenDTO result) {
        this.code = result.getErrcode();
        this.message = result.getErrmsg();
    }

    public WeChatExceptionCode(UserInfoAccessTokenDTO result) {
        this.code = result.getErrcode();
        this.message = result.getErrmsg();
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
